<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>
        编写一个函数，排序数字，按从小到大的顺序输出。
    </p>
    <input type="text" placeholder="请输入任意数量的数字">
    <input type="button" value="计算" onclick="getResult()">
    <span id="span"></span>
    <script>
        function getResult() {
            let str = document.querySelector('input').value;
            let strArr = str.split('');//分割字符串，将其转换成数组
            for (let i = 0; i < strArr.length - 1; i++) {
                for (let j = 0; j < strArr.length - 1 - i; j++) {
                    if (strArr[j] > strArr[j + 1]) {
                        let temp = strArr[j + 1];
                        strArr[j + 1] = strArr[j];
                        strArr[j] = temp;
                    }
                }
            }
            document.getElementById('span').innerHTML = strArr;
        }
    </script>
</body>

</html>